package org.dromara.system.domain.vo;

import java.math.BigDecimal;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.dromara.device.api.domain.vo.OrdinaryDeviceVo;
import org.dromara.system.domain.SysStore;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import org.dromara.common.excel.annotation.ExcelDictFormat;
import org.dromara.common.excel.convert.ExcelDictConvert;
import io.github.linpeilie.annotations.AutoMapper;
import org.dromara.system.domain.bo.BusinessTimeInfo;

import java.io.Serial;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;


/**
 * 系统管理-门店配置视图对象 sys_store
 *
 * @author LionLi
 * @date 2024-03-18
 */
@ExcelIgnoreUnannotated
//@AutoMapper(target = SysStore.class)
public class SysStoreVo implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 门店id
     */
    @ExcelProperty(value = "门店id")
    private Long storeId;

    /**
     * 区域id（sys_area表所在区域id）
     */
    @ExcelProperty(value = "区域id", converter = ExcelDictConvert.class)
    @ExcelDictFormat(readConverterExp = "s=ys_area表所在区域id")
    private Long groupId;

    /**
     * 区域id和区域祖级列表（如：区域id，区域祖级列表）
     */
    @ExcelProperty(value = "区域id和区域祖级列表", converter = ExcelDictConvert.class)
    @ExcelDictFormat(readConverterExp = "如=：区域id，区域祖级列表")
    private String groupIds;

    /**
     * 门店名称
     */
    @ExcelProperty(value = "门店名称")
    private String storeName;

    /**
     * 行政区域编码（如：420102）
     */
    @ExcelProperty(value = "行政区域编码", converter = ExcelDictConvert.class)
    @ExcelDictFormat(readConverterExp = "如=：420102")
    private Long areaId;

    /**
     * 所在省（如：湖北省）
     */
    @ExcelProperty(value = "所在省", converter = ExcelDictConvert.class)
    @ExcelDictFormat(readConverterExp = "如=：湖北省")
    private String province;

    /**
     * 所在市（如：武汉市）
     */
    @ExcelProperty(value = "所在市", converter = ExcelDictConvert.class)
    @ExcelDictFormat(readConverterExp = "如=：武汉市")
    private String city;

    /**
     * 经度（自动填充，在线地图选点）
     */
    @ExcelProperty(value = "经度", converter = ExcelDictConvert.class)
    @ExcelDictFormat(readConverterExp = "自=动填充，在线地图选点")
    private BigDecimal longitude;

    /**
     * 维度（自动填充，在线地图选点）
     */
    @ExcelProperty(value = "维度", converter = ExcelDictConvert.class)
    @ExcelDictFormat(readConverterExp = "自=动填充，在线地图选点")
    private BigDecimal latitude;

    /**
     * 门店编号（用户输入）
     */
    @ExcelProperty(value = "门店编号", converter = ExcelDictConvert.class)
    @ExcelDictFormat(readConverterExp = "用=户输入")
    private String storeCode;

    /**
     * 门店联系人(sys_user用户id)
     */
    @ExcelProperty(value = "门店联系人(sys_user用户id)")
    private Long storeManagerId;

    /**
     * 门店联系人电话
     */
    @ExcelProperty(value = "门店联系人电话")
    private String contactMobile;

    /**
     * 门店状态（字典表：IN_BUSINESS运行 SUSPEND暂停 CLOSING关闭）
     */
    @ExcelProperty(value = "门店状态", converter = ExcelDictConvert.class)
    @ExcelDictFormat(readConverterExp = "字=典表：IN_BUSINESS运行,S=USPEND暂停,C=LOSING关闭")
    private String storeStatus;

    /**
     * 门店营业时间（EVERYDAY每天，MON 每周一，WED 每周二，TUE 每周三，FRI 每周五，SAT 每周六，SUN 每周日，THU 每周四）如：[{"loopType":  [ "FRI","SAT","SUN","THU"],"duration":  [{ "start": "10:00", "end":  "22:00"}]}]
     */
   @TableField(typeHandler = com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler.class)
    private Object businessTimeInfo;

    /**
     * 门店面积（用户输入）
     */
    @ExcelProperty(value = "门店面积", converter = ExcelDictConvert.class)
    @ExcelDictFormat(readConverterExp = "用=户输入")
    private Long storeArea;

    /**
     * 门店地址（用户输入）
     */
    @ExcelProperty(value = "门店地址", converter = ExcelDictConvert.class)
    @ExcelDictFormat(readConverterExp = "用=户输入")
    private String detailAddress;

    /**
     * 门店所在位置（自动填充，通过地图定位自动带入，如：湖北省武汉市江岸区三阳路128-130号三阳广场-A座）
     */
    @ExcelProperty(value = "门店所在位置", converter = ExcelDictConvert.class)
    @ExcelDictFormat(readConverterExp = "自=动填充，通过地图定位自动带入，如：湖北省武汉市江岸区三阳路128-130号三阳广场-A座")
    private String address;

    /**
     * 门店所在商场id（下拉列表选择，商场表id）
     */
    @ExcelProperty(value = "门店所在商场id", converter = ExcelDictConvert.class)
    @ExcelDictFormat(readConverterExp = "下=拉列表选择，商场表id")
    private Long shoppingMallId;


    /**
     * 店铺联系人名称
     */
   private String storeManagerName;


    /**
     * 创建时间
     */
    private String createTime;

    /**
     * 门店标签集合
     */
    private List<SysLabelVo> storeLabels;


    /**
     * 祖籍id集合
     */
    private List<String> groupIdList;

    /**
     * 设备数量
     */
    public Integer deviceNum;

    /**
     * 设备信息
     */
    public List<OrdinaryDeviceVo>  devices;


    /**
     * 上级区域名称
     */
    private String groupName;


    /**
     * 在线设备
     */
    public Long onlineDevice;


    public String getStoreManagerName() {
        return storeManagerName;
    }

    public void setStoreManagerName(String storeManagerName) {
        this.storeManagerName = storeManagerName;
    }

    /**
     * 门店下关联的用户
     */
   public List<SysUserVo>  users;


    public List<SysUserVo> getUsers() {
        return users;
    }

    public void setUsers(List<SysUserVo> users) {
        this.users = users;
    }

    public String getGroupName() {
        return groupName;
    }

    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public Long getOnlineDevice() {
        return onlineDevice;
    }

    public void setOnlineDevice(Long onlineDevice) {
        this.onlineDevice = onlineDevice;
    }

    public List<OrdinaryDeviceVo> getDevices() {
        return devices;
    }

    public void setDevices(List<OrdinaryDeviceVo> devices) {
        this.devices = devices;
    }

    public Integer getDeviceNum() {
        return deviceNum;
    }

    public void setDeviceNum(Integer deviceNum) {
        this.deviceNum = deviceNum;
    }

    public List<String> getGroupIdList() {
        return Arrays.stream(this.groupIds.split(","))
                .collect(Collectors.toList());
    }

    public void setGroupIdList(List<String> groupIdList) {
        this.groupIdList = groupIdList;
    }

    public Long getStoreId() {
        return storeId;
    }

    public void setStoreId(Long storeId) {
        this.storeId = storeId;
    }

    public Long getGroupId() {
        return groupId;
    }

    public void setGroupId(Long groupId) {
        this.groupId = groupId;
    }

    public String getGroupIds() {
        return groupIds;
    }

    public void setGroupIds(String groupIds) {
        this.groupIds = groupIds;
    }

    public String getStoreName() {
        return storeName;
    }

    public void setStoreName(String storeName) {
        this.storeName = storeName;
    }

    public Long getAreaId() {
        return areaId;
    }

    public void setAreaId(Long areaId) {
        this.areaId = areaId;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public BigDecimal getLongitude() {
        return longitude;
    }

    public void setLongitude(BigDecimal longitude) {
        this.longitude = longitude;
    }

    public BigDecimal getLatitude() {
        return latitude;
    }

    public void setLatitude(BigDecimal latitude) {
        this.latitude = latitude;
    }

    public String getStoreCode() {
        return storeCode;
    }

    public void setStoreCode(String storeCode) {
        this.storeCode = storeCode;
    }

    public Long getStoreManagerId() {
        return storeManagerId;
    }

    public void setStoreManagerId(Long storeManagerId) {
        this.storeManagerId = storeManagerId;
    }

    public String getContactMobile() {
        return contactMobile;
    }

    public void setContactMobile(String contactMobile) {
        this.contactMobile = contactMobile;
    }

    public String getStoreStatus() {
        return storeStatus;
    }

    public void setStoreStatus(String storeStatus) {
        this.storeStatus = storeStatus;
    }

    public  List<BusinessTimeInfo> getBusinessTimeInfo() throws JsonProcessingException {
        ObjectMapper objectMapper = new ObjectMapper();
        List<BusinessTimeInfo> businessTimeInfos = objectMapper.readValue(this.businessTimeInfo.toString(), new TypeReference<List<BusinessTimeInfo>>() {});
        return businessTimeInfos;
    }

    public void setBusinessTimeInfo(Object businessTimeInfo) {
        this.businessTimeInfo = businessTimeInfo;
    }

    public Long getStoreArea() {
        return storeArea;
    }

    public void setStoreArea(Long storeArea) {
        this.storeArea = storeArea;
    }

    public String getDetailAddress() {
        return detailAddress;
    }

    public void setDetailAddress(String detailAddress) {
        this.detailAddress = detailAddress;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public Long getShoppingMallId() {
        return shoppingMallId;
    }

    public void setShoppingMallId(Long shoppingMallId) {
        this.shoppingMallId = shoppingMallId;
    }

    public List<SysLabelVo> getStoreLabels() {
        return storeLabels;
    }

    public void setStoreLabels(List<SysLabelVo> storeLabels) {
        this.storeLabels = storeLabels;
    }

    public String getLabel(){
        return  this.storeName;
    }
}
